package com.jiazhong.example.project.bookstore.front.test;

import com.jiazhong.example.project.bookstore.commons.bean.Logistics;
import com.jiazhong.example.project.bookstore.commons.bean.User;
import com.jiazhong.example.project.bookstore.commons.util.JsonResult;
import com.jiazhong.example.project.bookstore.front.service.LogisticsService;
import com.jiazhong.example.project.bookstore.front.service.UserService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.stereotype.Component;

import java.util.List;

@SpringBootTest
@Slf4j
@Component
public class App {
    @Resource
    private LogisticsService logisticsService;
    @Resource
    private UserService userService;
    @Resource
    private HttpServletRequest request;

    @Test
    public void a() {
        User user = new User();
        user.setUsername("admin");
        user.setPassword("123456");
        JsonResult login = userService.login(user);
        log.info("<login>:{}", login);
    }

    @Test
    public void b() {
        String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhZG1pbiIsInN1YiI6ImRhaWx5Ymx1ZSIsImlhdCI6MTc1NjEwODkzMCwiZXhwIjoxNzU2MTk1MzMwLCJpZCI6IjE1MjEyOTQ4NzIzMzAzOTE1NTUiLCJuYW1lIjoiYWRtaW4ifQ.BumoTeTGrkdpqKhqTZ9m8oGG6ZelRgpIt18e_Gi_lqg";
        JsonResult result = logisticsService.findLogisticsByUserId(token);
        log.info("result:{}", result);
    }

    @Test
    public void c() {
        String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhZG1pbiIsInN1YiI6ImRhaWx5Ymx1ZSIsImlhdCI6MTc1NjEwODkzMCwiZXhwIjoxNzU2MTk1MzMwLCJpZCI6IjE1MjEyOTQ4NzIzMzAzOTE1NTUiLCJuYW1lIjoiYWRtaW4ifQ.BumoTeTGrkdpqKhqTZ9m8oGG6ZelRgpIt18e_Gi_lqg";
        Logistics logistics = new Logistics();
        logistics.setLogisticsAddress("陕西省西安市雁塔区长安南路199号");
        logistics.setLogisticsName("张三");
        logistics.setLogisticsPhone("19987652345");
        logistics.setStatus(1);
        JsonResult result = logisticsService.saveLogistics(logistics, token);
        log.info("result:{}", result);
    }
}
